<script setup lang="ts">
import { ref, watch } from 'vue';


let text=ref("");

const jiinci=["你","我","他"];

let isRed=ref(false);
watch(
    ()=>text.value,
    (nv,ov)=>{
         jiinci.forEach(s=>{
            if(nv.includes(s)){
                isRed.value=true
                // let hefa_text=nv.substring(0,nv.length -1);
                // text.value=hefa_text;
                // alert("有禁词")
            }
        })
    }
)
</script>
<template>

<div>
    <input type="text" placeholder="请输入" v-model="text" class="input_bg_yellow"
    :class="{input_bg_red:isRed}">
</div>
</template>
<style scoped>
.input_bg_yellow{
    background-color: antiquewhite;
}

.input_bg_red{
    background-color: red;
}
</style>
